<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>视盾科技-修改密码</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/common.css">
	
	<style type="text/css">
		.updatepwd_div{
			margin-top:200px;
		}
		.updatepwd_btn{
			width:120px;
			margin-left:70px;
		}
	</style>
  </head>
  
  <body >
  
  	<jsp:include page="common.jsp"></jsp:include>
	
	<div class="right" style="background-color:red;"> 
		
		<!-- 这里单纯的使用一个div 没有布局成功，现在使用的是三个div，第一个和第三个只是起到布局效果 -->
		<div class="updatepwd_div">
			<div class="cotainer col-lg-4 col-md-4 col-sm-3"></div>
			<div class="cotainer col-lg-4 col-md-4 col-sm-6 col-xs-12 content_vcenter">
				<form role="form" action="" class="">
					<input type="hidden" name="uuid" id="updatepasswd_uuid" value="${currentUser.uuid }">
				
						<h4>原密码</h4>
						<div class="form-group">  
							<input type="password" name="oldpwd" id="oldpwd"
							class="form-control popover-show  " placeholder="input your password">
							<span id="pwdError" class="errorTxt"></span>
						</div>
						<h4>新密码</h4>
						<div class="form-group">  
							<input type="password" name="pwd" id="newpwd"
							class="form-control popover-show  " placeholder="input your password">
							<span id="pwdError" class="errorTxt"></span>
						</div>
						<h4>重复密码</h4>   
						<div class="form-group">  
							<input type="password" name="" id="renewpwd" 
								class="form-control popover-show  "  placeholder="input your password again">
							<span id="repwdError" class="errorTxt"></span>
						</div>
					<button type="button" class="btn btn-primary updatepwd_btn" id="updatepasswd_save_btn">保存</button>
					<button type="button" class="btn btn-primary updatepwd_btn" id="updatepasswd_reset_btn">重设</button>
				</form>
			</div>  
			<div class="cotainer col-lg-4 col-md-4 col-sm-3"></div> 
		</div> 
	
	
	</div>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/resources/jquery.md5.js"></script>
	<script type="text/javascript">
	
	//保存
	$("#updatepasswd_save_btn").bind('click',function(){
		if(validatePwd()){
			$.post("adminUserAction_updateUser.action",{
				"oldpwd":$.md5($("#oldpwd").val()), 
				"pwd":$.md5($("#newpwd").val())
			},function(res){
				res=eval('('+res+')');
				if(res.rescode=='100'){
					showSucMsg(res.msg);
				}else{
					showWarnMsg(res.msg);
				}
			});
		}
	});
	//重设 
	$("#updatepasswd_reset_btn").click(function(){
		$('input').val('');
	});
	//原密码输入完毕
	$("#oldpwd").blur(function(){
		$.post("adminUserAction_validOldPwd.action",{
			"pwd":$.md5($("#oldpwd").val())
		},function(res){
			res=eval('('+res+')');
			if(res.rescode=='-100'){
				showWarnMsg(res.msg);
				return;
			}
		});
	});
	//新密码输入完毕
	$("#newpwd").blur(function(){
		var value=$("#newpwd").val();//获取输入框内容
		if(!value){
			/* $("#pwdError").text("密码不能为空"); */
			showWarnMsg("新密码不能为空");
			return ;
		}
		if(value.length<6||value.length>20){
			/* $("#pwdError").text("密码长度在6~20之间"); */
			showWarnMsg("密码长度在6~20之间");
			return;
		}
	});
	//重复密码输入完毕
	$("#renewpwd").blur(function(){
			var value=$("#renewpwd").val();//获取输入框内容
			if(!value){
				showWarnMsg("重复密码不能为空");
				return;
			}
			/**
			 * 两次输入是否一致校验 
			 */
			if(value!=$("#newpwd").val()){
				showWarnMsg("两次输入的密码不一致");
				return ;
			}
			return;
	});
	
	function validatePwd(){
		var value=$("#newpwd").val();//获取输入框内容
		var oldvalue=$("#oldpwd").val();//获取输入框内容
		if(!value){
			/* $("#pwdError").text("密码不能为空"); */
			showWarnMsg("新密码不能为空");
			return false;
		}
		if(!oldvalue){
			/* $("#pwdError").text("密码不能为空"); */
			showWarnMsg("旧密码不能为空");
			return false;
		}
		/**
		 * 两次输入是否一致校验
		 */
		if(value.length<6||value.length>20){
			/* $("#pwdError").text("密码长度在6~20之间"); */
			showWarnMsg("密码长度在6~20之间");
			return false;
		}
		/**
		 * 两次输入是否一致校验
		 */
		if(oldvalue.length<6||oldvalue.length>20){
			/* $("#pwdError").text("密码长度在6~20之间"); */
			showWarnMsg("密码长度在6~20之间");
			return false;
		}
		if(value!=$("#renewpwd").val()){
			showWarnMsg("两次输入的密码不一致");
			return ;
		}
		return true;
	}
	
	</script>
	
  </body>
</html>
